let coupons=document.querySelector('.coupons')
let xhr =new XMLHttpRequest()
xhr.open('get','http://chst.vip:1234/api/getcoupon',true)
xhr.onload=function(){
    if(xhr.status===200){
        let res =JSON.parse(xhr.responseText)
        let an=res .result
        let lis=''
        an.forEach(item => {
         lis+=`
                <p couponId=${item.couponId}>${item.couponTitle}</p>
            ` 
        });
        coupons.innerHTML=lis
    }
}
xhr.send(null)

coupons.onclick=function(e){
    var e=e || window.event
    var target=e.target || e.src.Element
    localStorage.setItem('couponId',target.getAttribute('couponId'))
    location.href = 'http://127.0.0.1:5500/js/day18/html/kfc.html';

}